home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tags18.zip / SORT.H < prev    next >
Text File  |  1991-09-25  |  8KB  |  255 lines

  1. /*
  2.  EPSHeader
  3.  
  4.    File: sort.h
  5.    Author: J. Kercheval
  6.    Created: Wed, 05/15/1991  21:57:06
  7. */
  8.  
  9. /*---------------------------------------------------------------------------
  10. *
  11. *  09-10-91
  12. *
  13. *    Add support for external cleanup routine on signal exit when used
  14. *    as a separate module
  15. *
  16. *                                jbk
  17. *  09-05-91
  18. *
  19. *    Fixed a bug when using sort as a module.  Output file was not being
  20. *    closed.  Sort.exe relied on the exit code to close the output file.
  21. *
  22. *                                jbk
  23. *  07-19-91
  24. *
  25. *    Fixed an insidious little bug which prevented duplicate symbol delete
  26. *    when key fields or parameters were in use (ie sort -u -f ).
  27. *
  28. *                                jbk
  29. *  05-15-91
  30. *
  31. *    Calling this routine with all the requested filename in argv and the
  32. *    number of parameters in argc will yeild a sorted set of files in one
  33. *    output block.  Normal command line parameters may be passed as noted
  34. *    below.
  35. *
  36. *                                jbk
  37. *
  38. *
  39. *    General introduction to GNU `sort'.
  40. *    ***********************************
  41. *
  42. *    This is an MS-DOS port of the (unreleased) external sort program for
  43. *    the GNU project, written by Mike Haertel.
  44. *
  45. *       * *PLEASE NOTE*:  Mike Haertel (the original author) allowed me to
  46. *         distribute this program under the condition that I make clear
  47. *         that this program has not been tested extensively and is to be
  48. *         considered as in a pre-alpha test state.
  49. *
  50. *    I have decided to distribute this program anyway, because it
  51. *    outclasses *any* external sort program I have seen for MS-DOS: both
  52. *    in performance and functionality.
  53. *
  54. *       * Performance:
  55. *
  56. *           1. When used with a fast (preferably cached) disk, this
  57. *              program is as fast as V. Buerg's `sortf' (if the latter is
  58. *              used with large, non default keys, GNU `sort' is
  59. *              *considerably* faster).
  60. *
  61. *           2. There are (almost) no build-in hard limits!  (I have put
  62. *              one hard and one soft limit in the MS-DOS version, *note
  63. *              MS-DOS::.).
  64. *
  65. *       * Functionality:
  66. *
  67. *           1. GNU `sort' works as a filter.
  68. *
  69. *           2. GNU `sort' has lots of *useful* options (*note Options::.).
  70. *
  71. *    This distribution is different from the other ports of GNU software
  72. *    for MS-DOS: it contains the full, unabridged source code and no
  73. *    context diffs.  This is because GNU `sort' has not yet been released
  74. *    by the Free Software Foundation, and therefore you can't pick up the
  75. *    official source from prep.  But: *all* changes (which are very few)
  76. *    are conditionalized with `MSDOS'.
  77. *
  78. *    Please send bug reports (preferably with fixes (*context* `diff''s!) to
  79. *
  80. *               Thorsten Ohl
  81. *               <td12@ddagsi3.bitnet>
  82. *
  83. *    I can make no promises to fix it immediately, but I might want to!
  84. *
  85. *
  86. *    How to install the MS-DOS version of GNU `sort'.
  87. *    ************************************************
  88. *
  89. *      1. Edit the following variables in the makefile
  90. *
  91. *        `LIBS'
  92. *              Remove `glob.obj', `msd_dir.obj', and `_cwild.obj' if you
  93. *              don't have `glob.c', `msd_dir.c', `msd_dir.h', and
  94. *              `_cwild.c' from the other MS-DOS ports (e.g. fileutils), or
  95. *              if you do not want a reasonable filename globbing.
  96. *
  97. *        `VPATH'
  98. *              Include path for `glob.c', `msd_dir.c', `msd_dir.h', and
  99. *              `_cwild.c' on *your* system.  If you have a loosing (non
  100. *              GNU) `make' that doesn't understand `VPATH', copy the
  101. *              sources in your current directory.
  102. *
  103. *        `CFLAGS, LDFLAGS'
  104. *              These are for the Microsoft C compiler Version 6.0, edit
  105. *              them for your system:
  106. *
  107. *             `-AC'
  108. *                   Compact memory model
  109. *
  110. *             `-W4'
  111. *                   Full warnings!
  112. *
  113. *             `-Ocgilt'
  114. *                   (Almost) maximal optimization.
  115. *
  116. *             `-Za'
  117. *             `-DSTDC_HEADERS'
  118. *                   ANSI C.
  119. *
  120. *             `-DUSG'
  121. *                   Microsoft's C looks more like System V than BSD.
  122. *
  123. *             `/e'
  124. *                   Pack the executable.
  125. *
  126. *             `/st:0x8000'
  127. *                   Large stack.
  128. *
  129. *             `/noe'
  130. *                   If duplicate symbols in object files and libraries,
  131. *                   use the one from the object file.
  132. *
  133. *      2. Say `make'.
  134. *
  135. *    That's all.
  136. *
  137. *
  138. *    Options for GNU `sort'
  139. *    **********************
  140. *
  141. *         `sort' [-cmuV] [-t c] [-o `file'] [-T `dir']
  142. *                [-bdfiMnr] [+n [-m] ...] [`file' ...]
  143. *
  144. *    The following is a guide to GNU `sort', *not* a collection of
  145. *    *documented options* that can be relied on.
  146. *
  147. *    * Menu:
  148. *
  149. *    * Global::         Options affecting all sort keys together.
  150. *    * Keys::           Specification of the sort keys.
  151. *    * Local::          Options for one or all sort keys.
  152. *
  153. *
  154. *    Options affecting all sort keys
  155. *    ===============================
  156. *
  157. *    `-c'
  158. *         Check sort order  only.
  159. *
  160. *    `-m'
  161. *         Merge presorted files (avoids resorting of already sorted files,
  162. *         which is generally a slow operation).
  163. *
  164. *    `-o`file''
  165. *         Send output to `file' (overwriting).
  166. *
  167. *    `-tc'
  168. *         Use c as field separator.
  169. *
  170. *    `-T`prefix''
  171. *         Use `prefix' as prefix for temporary files (e.g.
  172. *         `prefix/sort3141.137'), default is `$TMP'.
  173. *
  174. *    `-u'
  175. *         Delete duplicate lines from the output.
  176. *
  177. *    `-V'
  178. *         Print the version string
  179. *
  180. *    *Note Local:: for more options that can affect all keys.
  181. *
  182. *
  183. *    How to specify the sort keys
  184. *    ============================
  185. *
  186. *    Keys are zero based, thus the first field has number 0, and so on.
  187. *
  188. *    `+num1.num2'
  189. *         Start a new key at character num2 of field num1.
  190. *
  191. *    `-num1.num2'
  192. *         Extend the key upto (not including) character num2 of field num1.
  193. *
  194. *
  195. *    Options affecting one or all sort keys
  196. *    ======================================
  197. *
  198. *    These option apply either globally to all sort keys (if they are
  199. *    specified before the keys on the command line), or to a single key
  200. *    (if they are appended to the key specification).
  201. *
  202. *    `-b'
  203. *         Skip white space.
  204. *
  205. *    `-d'
  206. *         Dictionary mode: ignore punctuation.
  207. *
  208. *    `-f'
  209. *         Fold to lowercase.
  210. *
  211. *    `-i'
  212. *         Ignore nonprinting characters.
  213. *
  214. *    `-M'
  215. *         Sort as english (three character) month names.
  216. *
  217. *    `-n'
  218. *         Sort numrically.
  219. *
  220. *    `-r'
  221. *         Sort in reverse.
  222. *
  223. *
  224. *    How the MS-DOS version differs
  225. *    ******************************
  226. *
  227. *       * The maximum line length has been reduced to 32k.  While the
  228. *         introduction of arbitrary upper limits is alien to the GNU
  229. *         project, this particular limit seems to be o.k. for MS-DOS
  230. *         applications and tremendously decreases the number of required
  231. *         changes in the original source.
  232. *
  233. *       * The maximum number of lines per input buffer is restricted to
  234. *         about 4000.  This limit can only be reached by files with an
  235. *         average linelength smaller that 8 characters.  To allow the
  236. *         sorting of such files, the following option has been included to
  237. *         reduce the input buffer size:
  238. *
  239. *        `-S num'
  240. *              Set the input buffer size (default 32k) to num.
  241. *
  242. ---------------------------------------------------------------------------*/
  243.  
  244. int sort_main(int argc, char *argv[]);
  245.  
  246. /*---------------------------------------------------------------------------
  247.  *
  248.  * external_cleanup() is called in the sort module but is not defined there.
  249.  * The caller of the sort module should define this routine which is called
  250.  * should there be an abnormal program termination handled by a signal.
  251.  *
  252.  *-------------------------------------------------------------------------*/
  253.  
  254. void external_cleanup(void);
  255.